//
//  XMTableViewCellFooterView.m
//  XMFriendCircleDemo
//
//  Created by chenming on 2018/1/26.
//  Copyright © 2018年 ChenXiaoMing. All rights reserved.
//

#import "XMTableViewCellFooterView.h"

@interface XMTableViewCellFooterView ()

@property (nonatomic, strong) UIView *bottomlineView;

@end

@implementation XMTableViewCellFooterView

+ (instancetype)footerViewWithTableView:(UITableView *)tableView {
    static NSString *const cellID = @"footerView";
    XMTableViewCellFooterView *footer = [tableView dequeueReusableHeaderFooterViewWithIdentifier:cellID];
    if(!footer) {
        footer = [[XMTableViewCellFooterView alloc] initWithReuseIdentifier:cellID];
        footer.contentView.backgroundColor = [UIColor whiteColor];
    }
    return footer;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.bottomlineView];
        [self.bottomlineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.contentView).offset(0);
            make.left.right.mas_equalTo(self.contentView).offset(0);
            make.height.equalTo(@(0.5));
        }];
        
    }
    return self;
}

- (UIView *)bottomlineView {
    if (!_bottomlineView) {
        _bottomlineView = [[UIView alloc] init];
        _bottomlineView.backgroundColor = [UIColor xm_colorWithHexString:@"C0C0C0" alpha:1];
    }
    return _bottomlineView;
}

+ (CGFloat)getSectionHeight {
    return 10;
}

- (void)setFrame:(CGRect)frame {
    // 设置起始位置
    CGRect sectionRect = [self.tableView rectForSection:self.section];
    CGRect newFrame = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(sectionRect) - 20, CGRectGetWidth(frame), CGRectGetHeight(frame));
    [super setFrame:newFrame];
}

@end
